package com.yunji.coupon.dto;

import com.yunji.common.model.cache.ProductCacheDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;

/**
 * @author : peter-zhu
 * @date : 2024/10/29 16:45
 * @description : TODO
 **/
@AllArgsConstructor
@NoArgsConstructor
@Data
public class OrderAmtDTO {
    // 订单明细需要商品来进行合并
    @ApiModelProperty(hidden = true)
    private ProductCacheDTO productCacheDTO;
    @ApiModelProperty("原价格")
    private BigDecimal price = BigDecimal.ZERO;
    @ApiModelProperty("折扣后的价格")
    private BigDecimal discountAmount = BigDecimal.ZERO;
    // 有优惠券的时候才会用到这个属性 此对象作为订单头才有  订单明细忽略此属性
    @ApiModelProperty("优惠券的价格")
    private BigDecimal coupleAmount = BigDecimal.ZERO;
    @ApiModelProperty("(实付价)折扣后的价格再减去优惠券的价格")
    private BigDecimal payableAmount = BigDecimal.ZERO;
    @ApiModelProperty("折扣减掉的价(不包含优惠券)=price(原价格)-discountAmount(折扣后的价格)")
    private BigDecimal subtractAmount = BigDecimal.ZERO;
    //    @ApiModelProperty("一共减掉的价")
//    private BigDecimal subtractSumAmount = BigDecimal.ZERO;
    @ApiModelProperty(hidden = true)
    private BigDecimal costPrice = BigDecimal.ZERO;

    @ApiModelProperty(hidden = true)
    private Integer productNums = 0;

    public OrderAmtDTO add(OrderAmtDTO amt) {
        this.price = this.price.add(amt.getPrice());
        this.discountAmount = this.discountAmount.add(amt.getDiscountAmount());
        this.payableAmount = this.payableAmount.add(amt.getPayableAmount());
        this.subtractAmount = this.subtractAmount.add(amt.getSubtractAmount());
        this.costPrice = this.costPrice.add(amt.getCostPrice());
        return this;
    }

    @ApiModelProperty(hidden = true)
    private Long siteId;
}
